package sysAuth

import initConfig.SysInitData
import sysUtil.SysCommUtil

class SysRoleRelaOperat {

    Long relaId;
    Long sysFunOptId

    static mapping = {
        version false
    }

    static constraints = {
        relaId(unique: "sysFunOptId")
    }

    static init(){
        if(SysRoleRelaOperat.count == 0){
            def role = SysRoles.findByRoleNoAndRoleType(SysInitData.TEST_NAME,SysInitData.FUNC_ROLE)
            def sysRoleRela = SysRoleRela.findByRoleAndDataId(role,SysFunctions.findByFuncNo("SYS_USER").id)

            SysFunOpt.findAllByOperateNotInListAndFunction(SysOperations.findAllByOperateNoInList(['monitor','upLoad','detail']),SysFunctions.get(sysRoleRela.dataId) ).each {op ->
                new SysRoleRelaOperat(relaId : sysRoleRela.id,sysFunOptId : op.id).save(flush: true)
            }
        }
    }
}
